#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 5;
int n, h[N];
int f[N], g[N];
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    cin >> n;
    int res = -1;
    for (int i = 0; i < n; ++i) cin >> h[i];
    for (int i = 0; i < n; ++i) {
      f[i] = 1;
      for (int j = 0; j < i; ++j)
        if (h[i] < h[j]) f[i] = max(f[j] + 1, f[i]);
      res = max(res, f[i]);
    }

    memset(f, 0, sizeof(f));
    for (int i = n - 1; i >= 0; --i) {
      f[i] = 1;
      for (int j = n - 1; j > i; --j) {
        if (h[i] < h[j]) f[i] = max(f[i], f[j] + 1);
      }
      res = max(res, f[i]);
    }
    cout << res << endl;
  }
}
